$(function() {
	processPage();
});
function processPage() {
	var pageIndex = $('#pageIndex').val() == '' ? 1 : $('#pageIndex').val();
	var pageSize = $('#pageSize').val();
	var rowsCount = $('#rowsCount').val();
	//加入分页的绑定 
	$("#Pagination").pagination(rowsCount, {
		callback : pageselectCallback,
		prev_text : '< 上一页', 
  		next_text: '下一页 >',
		items_per_page : pageSize,
		num_display_entries : 6,
		current_page : pageIndex - 1,
		num_edge_entries : 1
	});
}
function pageselectCallback(page_id, jq) {
	var pageIndex = $('#pageIndex').val() == '' ? 1 : $('#pageIndex').val();
	if (pageIndex == page_id + 1){
		return false;
	}
	$('#pageIndex').val(page_id + 1);
	$('#form').submit();
}
function checkIds(ids) {
	if (ids.length < 1) {
		layer.msg('请至少选择一条数据！！', {
			icon : 5,
			time : 1000
		});
		return false;
	}
	return true;
}
function getCheckIds(name) {
	var ids = "";
	$("input[name=" + name + "]").each(function() {
		if ($(this).is(':checked'))
			ids += $(this).val() + ",";
	});
	if (ids.length > 1) {
		ids = ids.substring(0, ids.length - 1);
	}
	return ids;
}
function ajaxSubmit(method, url, params){
	jQuery.ajax({  
        type : method,  
        contentType : 'application/json', 
        url : url + "?" + params,
        success : function(data) {
      	  var rsult = jQuery.parseJSON(data);
      	  if (rsult.success) {
      		  //layer.msg(rsult.message, {icon:6,time:1000});
      		  window.location.reload();
      	  } else 
      		layer.msg("提交失败!原因:" + rsult.message, {icon:5,time:1000});
        },  
        error : function(data) {  
        	layer.msg('提交失败！', {icon:5,time:1000});
        }  
    });
}